package dl.domainmodel.strategy;

import dl.domainmodel.model.Contract;
import dl.domainmodel.model.RevenueRecognition;
import dl.martinfowler.wrapper.Money;

public class ThreeWayRecognitionStrategy extends RecognitionStrategy {

	private int firstRecognitionOffSet;
	private int secondRecognitionOffSet;

	public ThreeWayRecognitionStrategy(int firstRecognitionOffSet,
			int secondRecognitionOffSet) {
		this.firstRecognitionOffSet = firstRecognitionOffSet;
		this.secondRecognitionOffSet = secondRecognitionOffSet;
	}

	@Override
	public void calculateRevenueRecognitions(Contract contract) {
		Money[] allocation = contract.getRevenue().allocate(3);
		contract.addRevenueRecognition(new RevenueRecognition(allocation[0],
				contract.getWhenSigned()));
		contract.addRevenueRecognition(new RevenueRecognition(allocation[1],
				contract.getWhenSigned().addDays(firstRecognitionOffSet)));
		contract.addRevenueRecognition(new RevenueRecognition(allocation[2],
				contract.getWhenSigned().addDays(secondRecognitionOffSet)));

	}

}
